<template>
    <div>
      <el-form v-if="!searchState" size="small" :inline="true" class="query-form" ref="searchForm" :model="searchForm" @keyup.enter.native="refreshList()" @submit.native.prevent>
         <!-- <el-form-item prop="name">
                <el-input size="small" v-model="searchForm.name" placeholder="姓名" clearable></el-input>
         </el-form-item>
         <el-form-item prop="remarks">
                <el-input size="small" v-model="searchForm.remarks" placeholder="备注信息" clearable></el-input>
         </el-form-item> -->
         <el-form-item label="年" prop="createdate">
           <el-input-number v-model="createdate" controls-position="right" :min="2021" :max="9999"></el-input-number>
         </el-form-item>
         <el-form-item label="投票次数" prop="ticketCount">
           <el-input-number v-model="ticketCount" controls-position="right" :min="1" :max="9999"></el-input-number>
         </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="refreshList()" size="small">查询</el-button>
            <el-button @click="resetSearch()" size="small">重置</el-button>
          </el-form-item>
      </el-form>
        <!-- 导入导出-->
      <!-- <el-dialog  title="导入Excel" :visible.sync="isImportCollapse">
          <el-form size="small" :inline="true" v-show="isImportCollapse"  ref="importForm">
             <el-form-item>
              <el-button type="default" @click="downloadTpl()" size="small">下载模板</el-button>
             </el-form-item>
             <el-form-item prop="loginName">
                <el-upload
                  class="upload-demo"
                  :action="`${this.$http.BASE_URL}/ticket/crowdmiddleleader/crowdMiddleleader/import`"
                  :on-success="uploadSuccess"
                   :show-file-list="true">
                  <el-button size="small" type="primary">点击上传</el-button>
                  <div slot="tip" class="el-upload__tip">只允许导入“xls”或“xlsx”格式文件！</div>
                </el-upload>
            </el-form-item>
          </el-form>
      </el-dialog> -->
      <div class="bg-white top" style="height: 100%;">
      <div align="center" style="font-size: 26px;">
        <span style="font-size: 40px;">{{dataList[0].name}}</span>
        {{'\u00a0\u00a0\u00a0' + new Date().getFullYear() + '年度考核民主测评表'}}
        </div>
      <br>
      <el-row>
        <!-- <el-button v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:add')" type="primary" size="small" icon="el-icon-plus" @click="add()">新建</el-button>
        <el-button v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:edit')" type="warning" size="small" icon="el-icon-edit-outline" @click="edit()"
         :disabled="dataListSelections.length != 1" plain>修改</el-button>
        <el-button v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:del')" type="danger"   size="small" icon="el-icon-delete" @click="del()"
                  :disabled="dataListSelections.length <= 0" plain>删除
        </el-button> -->
        <el-button-group class="pull-right">
            <!-- <el-button v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:import')" type="default" size="small" icon="el-icon-upload2" title="导入" @click="isImportCollapse = !isImportCollapse"></el-button> -->
            <!-- <el-button v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:export')" type="default" size="small" icon="el-icon-download" title="导出" @click="exportExcel()"></el-button> -->
            <!-- <el-button
              type="default"
              size="small"
              icon="el-icon-refresh"
              @click="refreshList">
            </el-button> -->
        </el-button-group>
      </el-row>
    <div style="font-size: 35px;">
     {{'1.正向测评'}}
    </div>
    <el-table
      :data="dataList"
       size="small"
       style="width: 100%;border: 2px solid #76838F;"
       :header-cell-style="headerCellStyle"
       :cell-style="cellStyle"
      @selection-change="selectionChangeHandle"
      @sort-change="sortChangeHandle"
      v-loading="loading"
      class="table">
      <!-- <el-table-column
        type="selection"
        header-align="center"
        align="center"
        width="50">
      </el-table-column> -->
      <el-table-column align="center" label="测评项目">
        {{"总体评价"}}
        </el-table-column>
       <el-table-column
           align="center"
           prop="remarks"
           show-overflow-tooltip
           label="优秀">
           <template slot-scope="scope">
             <el-radio-group v-model="scope.row.remarks">
               <el-radio-button label="优秀" border>优秀</el-radio-button>
             </el-radio-group>
           </template>
         </el-table-column>
       <el-table-column
           align="center"
           prop="remarks"
           show-overflow-tooltip
           label="称职">
           <template slot-scope="scope">
             <el-radio-group v-model="scope.row.remarks">
               <el-radio-button label="称职" border>称职</el-radio-button>
             </el-radio-group>
           </template>
         </el-table-column>
       <el-table-column
           align="center"
           prop="remarks"
           show-overflow-tooltip
           label="基本称职">
           <template slot-scope="scope">
             <el-radio-group v-model="scope.row.remarks">
               <el-radio-button label="基本称职" border>基本称职</el-radio-button>
             </el-radio-group>
           </template>
         </el-table-column>
         <el-table-column
             align="center"
             prop="remarks"
             show-overflow-tooltip
             label="不称职">
             <template slot-scope="scope">
             <el-radio-group v-model="scope.row.remarks">
               <el-radio-button label="不称职" border>不称职</el-radio-button>
             </el-radio-group>
             </template>
           </el-table-column>
      </el-table-column>
      <!-- <el-table-column align="center" label="反向测评">

      </el-table-column>
      <el-table-column align="center" label="“五整治”专项测评">

      </el-table-column> -->
      <!-- <el-table-column
        header-align="center"
        align="center"
        fixed="right"
        v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:del')"
        :key="Math.random()"
        width="200"
        label="操作">
        <template  slot-scope="scope">
          <el-button v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:view')" type="text" icon="el-icon-view" size="small" @click="view(scope.row.id)">查看</el-button>
          <el-button v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:edit')" type="text" icon="el-icon-edit" size="small" @click="edit(scope.row.id)">修改</el-button>
          <el-button v-if="hasPermission('ticket:crowdmiddleleader:crowdMiddleleader:del')" type="text"  icon="el-icon-delete" size="small" @click="del(scope.row.id)">删除</el-button>
        </template>
      </el-table-column> -->
    </el-table>
    <br>
    <div style="font-size: 35px;">
     {{'2.反向测评'}}
    </div>
    <el-table
      :data="reverseList"
       size="small"
       style="width: 100%;border: 2px solid #76838F;"
       :header-cell-style="headerCellStyle"
       :cell-style="cellStyleFan"
      @selection-change="selectionChangeHandle"
      @sort-change="sortChangeHandle"
      v-loading="loading"
      class="tables">
        <el-table-column
          min-width="180px"
          prop="appraisalContent"
          align="left"
          header-align="center"
          class="cell"
          label="问题表现">
        </el-table-column>
        <el-table-column
            align="center"
            prop="fanRemarks"
            show-overflow-tooltip
            label="不存在">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.fanRemarks">
                <el-radio-button label="不存在" border>不存在</el-radio-button>
              </el-radio-group>
            </template>
          </el-table-column>
        <el-table-column
            align="center"
            prop="fanRemarks"
            show-overflow-tooltip
            label="轻微存在">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.fanRemarks">
                <el-radio-button label="轻微存在" border>轻微存在</el-radio-button>
              </el-radio-group>
            </template>
          </el-table-column>
        <el-table-column
            align="center"
            prop="fanRemarks"
            show-overflow-tooltip
            label="比较突出">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.fanRemarks">
                <el-radio-button label="比较突出" border>比较突出</el-radio-button>
              </el-radio-group>
            </template>
          </el-table-column>
      </el-table-column>
    </el-table>
    <br>
    <div style="font-size: 35px;">
     {{'3.“五整治”专项测评'}}
    </div>
    <el-table
      :data="fivePoliticalList"
       size="small"
       style="width: 100%;border: 2px solid #76838F;"
       :header-cell-style="headerCellStyle"
       :cell-style="cellStyleWu"
      @selection-change="selectionChangeHandle"
      @sort-change="sortChangeHandle"
      v-loading="loading"
      class="tables">
        <el-table-column
          min-width="180px"
          prop="appraisalContent"
          align="left"
          header-align="center"
          class="cell"
          label="问题表现">
        </el-table-column>
        <el-table-column
            align="center"
            prop="fiveRemarks"
            show-overflow-tooltip
            label="不存在">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.fiveRemarks">
                <el-radio-button label="不存在" border>不存在</el-radio-button>
              </el-radio-group>
            </template>
          </el-table-column>
        <el-table-column
            align="center"
            prop="fiveRemarks"
            show-overflow-tooltip
            label="轻微存在">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.fiveRemarks">
                <el-radio-button label="轻微存在" border>轻微存在</el-radio-button>
              </el-radio-group>
            </template>
          </el-table-column>
        <el-table-column
            align="center"
            prop="fiveRemarks"
            show-overflow-tooltip
            label="比较突出">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.fiveRemarks">
                <el-radio-button label="比较突出" border>比较突出</el-radio-button>
              </el-radio-group>
            </template>
          </el-table-column>
      </el-table-column>
    </el-table>
    <!-- <el-table
      :data="fivePoliticalList"
       size="small"
      @selection-change="selectionChangeHandle"
      @sort-change="sortChangeHandle"
      v-loading="loading"
      class="table">

    </el-table> -->
    <!-- <el-col :span="24">
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageNo"
      :page-sizes="[1]"
      :page-size="pageSize"
      :total="total"
      background
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    </el-col> -->
    </el-row>
    <div align="center" style="font-size: 26px;">{{pageNo + '/' + total + '页'}}</div>
    <el-row style="margin-left: 45%;">
      <el-button v-show="pageNo === 1 && isClose" type="primary"  size="big" @click="jumpUp()">上一页</el-button>
      <el-button class="button1" v-show="pageNo !== 1" type="primary"  size="big" @click="pageCount('pre')">上一页</el-button>
      <el-button class="button2" v-show="pageNo !== total" type="primary" size="big" @click="pageCount('next')">下一页</el-button>
      <el-button v-show="pageNo === total && submitState && searchState" type="primary" size="big" @click="submit()">提交</el-button>
    </el-row>
    </div>
    <asyn-for-tool ref='asynForTool' @returnData='returnData(arguments)'></asyn-for-tool>
        <!-- 弹窗, 新增 / 修改 -->
    <!-- <CrowdMiddleleaderForm  ref="crowdMiddleleaderForm" @refreshDataList="refreshList"></CrowdMiddleleaderForm> -->
  </div>
</template>

<script>
  import {clearLoginInfo} from '@/utils'
  // import CrowdMiddleleaderForm from './CrowdMiddleleaderForm'
  export default {
    data () {
      return {
        searchForm: {
          name: '',
          unit: '',
          remarks: '',
          ticketCount: ''
        },
        isClose: false,
        createdate: new Date().getFullYear(),
        ticketCount: 1,
        state: false,
        loadings: '',
        fiveArr: [],
        reverseLists: [],
        reverseList: [],
        reverseArr: [],
        fivePoliticalList: [],
        fivePoliticalLists: [],
        dataLists: [],
        dataList: [],
        dataArr: [],
        pageNo: 1,
        pageSize: 1,
        total: 0,
        errList: '',
        orderBy: '',
        dataListSelections: [],
        isImportCollapse: false,
        loading: false,
        fanRemarkindpx: 0,
        fiveRemarkspx: 0,
        fanRemarkindflag: 0,
        fiveRemarkflag: 0,
        redisFiveCount: 0, // redis五整治缓存
        redisFanCount: 0 // redis反向缓存
      }
    },
    components: {
      // CrowdMiddleleaderForm
    },
    computed: {
      submitState () {
        return localStorage.getItem(localStorage.getItem('loginName') + 'submit') === null
      },
      searchState () {
        return localStorage.getItem('loginName') !== 'admin'
      }
    },
    watch: {
      'dataLists': {
        handler (newVal, oldVal) {
          if (newVal !== undefined && newVal !== null && newVal.length !== 0) {
            this.$http({
              url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
              method: 'post',
              data: {
                key: (localStorage.getItem('loginName') + this.$route.path + 'zheng'),
                value: JSON.stringify(newVal)
              }
            })
          }
        },
        deep: true
      },
      'reverseLists': {
        handler (newVal, oldVal) {
         if (newVal.length !== 0) {
             this.redisFanCount++
          if (this.redisFanCount >= 3) {
                this.$http({
                  url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
                  method: 'post',
                  data: {
                    key: (localStorage.getItem('loginName') + this.$route.path + 'reverseList'),
                    value: JSON.stringify(newVal)
                  }
                })
                this.redisFanCount = 0
              }
          }
        },
        deep: true
      },
      'fivePoliticalLists': {
        handler (newVal, oldVal) {
         if (newVal.length !== 0) {
             this.redisFiveCount++
          if (this.redisFiveCount >= 3) {
                this.$http({
                  url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
                  method: 'post',
                  data: {
                    key: (localStorage.getItem('loginName') + this.$route.path + 'fivePoliticalList'),
                    value: JSON.stringify(newVal)
                  }
                })
                this.redisFiveCount = 0
            }
          }
        },
        deep: true
      }
    },
    activated () {
      this.refreshList()
    },
    methods: {
      headerCellStyle ({row}) {
        return "font-size: 24px;border: 1px solid black;font-weight:bold;"
      },
      cellStyle ({row, column, rowIndex, columnIndex}) {
        if (this.state) {
          if (row.remarks === "" || row.remarks === undefined) {
            return "background:#d3d3d3;border:2px;color: #FFFFFF;font-size: 24px;border: 1px solid black;"
          }
        }
        return "font-size: 24px;border: 1px solid black;"
      },
      cellStyleFan ({row, column, rowIndex, columnIndex}) {
        if (this.state) {
          if (row.fanRemarks === "" || row.fanRemarks === undefined) {
            return "background:#d3d3d3;border:2px;color: #FFFFFF;font-size: 20px;border: 1px solid black;"
          }
        }
        return "font-size: 20px;border: 1px solid black;"
      },
      cellStyleWu ({row, column, rowIndex, columnIndex}) {
        if (this.state) {
          if (row.fiveRemarks === "" || row.fiveRemarks === undefined) {
            return "background:#d3d3d3;border:2px;color: #FFFFFF;font-size: 20px;border: 1px solid black;"
          }
        }
        return "font-size: 20px;border: 1px solid black;"
      },
      jumpUp () {
        this.$http({
          url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
          method: 'post',
          data: {
            key: (localStorage.getItem('loginName') + this.$route.path + 'zheng'),
            value: JSON.stringify(this.dataLists)
          }
        })
        this.$http({
          url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
          method: 'post',
          data: {
            key: (localStorage.getItem('loginName') + this.$route.path + 'reverseList'),
            value: JSON.stringify(this.reverseLists)
          }
        })
        this.$http({
          url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
          method: 'post',
          data: {
            key: (localStorage.getItem('loginName') + this.$route.path + 'fivePoliticalList'),
            value: JSON.stringify(this.fivePoliticalLists)
          }
        })
        if (this.$route.query.pathRouter === '/ticket/crowdleadershipfu/CrowdLeadershipFuList') {
          this.$router.push('/ticket/crowdleadershipfu/CrowdLeadershipFuList')
        } else if (this.$route.query.pathRouter === '/ticket/crowdleadershipteach/CrowdLeadershipTeachList') {
          this.$router.push('/ticket/crowdleadershipteach/CrowdLeadershipTeachList')
        }
      },
      // 提交成功
      submitSuccess () {
        this.$http({
          url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
          method: 'post',
          data: {
            key: localStorage.getItem('loginName') + 'state',
            value: '已填写'
          }
        })
      },
      // 退出登录
      out () {
        this.$http({
          url: '/sys/logout',
          method: 'get'
        }).then(({data}) => {
          if (data && data.success) {
            clearLoginInfo()
            if (process.env.VUE_APP_SSO_LOGIN === 'true') {
              let service = window.location.protocol + '//' + window.location.host + '/'
              window.location.href = `${process.env.VUE_APP_CAS_SERVER}/logout?service=${service}`
              this.$tool.flash()
            } else {
              this.$router.replace({name: 'login'})
              this.$tool.flash()
            }
          }
        })
      },
      // 提交数据
      submit () {
        this.pageValidation()
        var mergeArr = []
        if (this.errList === '') {
          this.state = false
          this.loading = true
          this.dataArr = []
          for (var i in this.dataLists) {
            this.$set(this.dataLists[i], 'tableName', 'crowd_middleleader')
            this.dataArr.push(this.lodash.pick(this.dataLists[i], 'remarks', 'name', 'mark', 'tableName', 'identity', 'currentPosition', 'ticketCount'))
          }
          mergeArr = mergeArr.concat(this.dataArr)
          for (var index in this.reverseLists) {
            this.reverseArr = []
            for (var j in this.reverseLists[index][0]) {
               this.$set(this.reverseLists[index][0][j], 'fan', this.reverseLists[index][0][j].fanRemarks)
               this.$set(this.reverseLists[index][0][j], 'name', this.dataLists[index].name)
               this.$set(this.reverseLists[index][0][j], 'currentPosition', this.dataLists[index].currentPosition)
               this.$set(this.reverseLists[index][0][j], 'mark', this.dataLists[index].mark)
               this.$set(this.reverseLists[index][0][j], 'tableName', 'crowd_middleleader')
               this.$set(this.reverseLists[index][0][j], 'identity', this.dataLists[index].identity)
               this.$set(this.reverseLists[index][0][j], 'ticketCount', this.dataLists[index].ticketCount)
               this.$set(this.reverseLists[index][0][j], 'appraisalContent', this.reverseLists[index][0][j].appraisalContent)
               this.reverseArr.push(this.lodash.pick(this.reverseLists[index][0][j], 'fan', 'name', 'mark', 'tableName', 'identity', 'currentPosition', 'ticketCount', 'appraisalContent'))
            }
            mergeArr = mergeArr.concat(this.reverseArr)
          }
          for (var k in this.fivePoliticalLists) {
            this.fiveArr = []
            for (var q in this.fivePoliticalLists[k][0]) {
              this.$set(this.fivePoliticalLists[k][0][q], 'five', this.fivePoliticalLists[k][0][q].fiveRemarks)
              this.$set(this.fivePoliticalLists[k][0][q], 'name', this.dataLists[k].name)
              this.$set(this.fivePoliticalLists[k][0][q], 'currentPosition', this.dataLists[k].currentPosition)
              this.$set(this.fivePoliticalLists[k][0][q], 'mark', this.dataLists[k].mark)
              this.$set(this.fivePoliticalLists[k][0][q], 'tableName', 'crowd_middleleader')
              this.$set(this.fivePoliticalLists[k][0][q], 'identity', this.dataLists[k].identity)
              this.$set(this.fivePoliticalLists[k][0][q], 'ticketCount', this.dataLists[k].ticketCount)
              this.$set(this.fivePoliticalLists[k][0][q], 'appraisalContent', this.fivePoliticalLists[k][0][q].appraisalContent)
              this.fiveArr.push(this.lodash.pick(this.fivePoliticalLists[k][0][q], 'five', 'name', 'mark', 'tableName', 'identity', 'currentPosition', 'ticketCount', 'appraisalContent'))
            }
            mergeArr = mergeArr.concat(this.fiveArr)
          }
            localStorage.setItem(localStorage.getItem('loginName') + 'submit', '1')
            this.$http({
              url: `/ticketdata/leadershipdata/leadershipData/manysave`,
              method: 'post',
              data: {
                account: localStorage.getItem('loginName'),
                finishState: '已完成',
                middlerleader: mergeArr,
                unitleader: this.$route.query.mergeArr
              }
            })
            this.submitSuccess()
            this.out()
        } else {
          this.state = true
          // 弹窗机构
          // this.$confirm(`<div style='font-size: 25px'>当前页面${this.errList}存在未填写数据！！</div>`, {
          //   customClass: "msgBox",
          //   dangerouslyUseHTMLString: true,
          //   showCancelButton: false,
          //   center: true
          // })
          this.pageCount('next')
        }
      },
      // 获取数据列表
      refreshList () {
        this.redisFanCount = 0
        this.redisFiveCount = 0
        this.loading = true
        if (localStorage.getItem(localStorage.getItem('loginName') + 'submit') !== null) {
          this.out()
        } else {
        if (localStorage.getItem('loginName') === 'admin') {
          if (this.createdate === '' || this.createdate === null || this.createdate === undefined || this.ticketCount === undefined || this.ticketCount === undefined || this.ticketCount === undefined) {
            this.searchForm.ticketCount = new Date().getFullYear() + '-' + 1
          } else {
            this.searchForm.ticketCount = this.createdate + '-' + this.ticketCount
          }
          this.searchForm.admin = 'admin'
        } else {
          this.searchForm.ticketCount = localStorage.getItem('checkTime')
          this.searchForm.admin = ''
        }
        this.dataList = []
        this.$http({
           url: `/sys/log/logId`,
           method: 'get'
         }).then(({data}) => {
           if (data.logId.name !== '管理员') {
             this.searchForm.unit = data.logId.name
             if (data.logId.roleIds === '2f5b4d568be04501a08833e4e0764eae') {
                this.isClose = false
             } else {
               this.isClose = true
             }
           } else {
             this.isClose = true
           }
           this.searchForm.key = localStorage.getItem('loginName') + this.$route.path + 'zheng'
           this.$http({
             url: '/ticket/crowdmiddleleader/crowdMiddleleader/list',
             method: 'get',
             params: {
               'pageNo': this.pageNo,
               'pageSize': 9999,
               'orderBy': this.orderBy,
               ...this.searchForm
             }
           }).then(({data}) => {
             if (data && data.success) {
               this.pageNo = 1
               if (data.msg === 'redis') {
                 this.dataLists = JSON.parse(data.value)
                 this.total = this.dataLists.length
                 this.dataList.push(this.dataLists[0])
               } else {
                 this.dataLists = data.page.list
                 this.total = data.page.count
                 this.dataList.push(this.dataLists[0])
               }
               this.detail('cffbf05bcaa44a5188e75adea98217e5', 'reverseList')
               this.detail('77f55a97e31f45168df1c6416ee2d3b7', 'fivePoliticalList')
               this.loading = false
           }
           })
         })
         }
      },
      // 当前页校验
      pageValidation () {
        this.errList = ''
        if (this.dataList[0].remarks === '' || this.dataList[0].remarks === undefined) {
          this.errList += ' 总体评价'
        }
        for (var index in this.reverseList) {
          if (this.reverseList[index].fanRemarks === '' || this.reverseList[index].fanRemarks === undefined) {
            this.errList += ' 反向测评'
            break
          }
        }
        for (var dex in this.fivePoliticalList) {
          if (this.fivePoliticalList[dex].fiveRemarks === '' || this.fivePoliticalList[dex].fiveRemarks === undefined) {
            this.errList += ' 五整治'
            break
          }
        }
      },
      // 页码
      pageCount (val) {
      var valPage = ''
      var listHead = document.getElementsByClassName('has-gutter')
      if (localStorage.getItem('loginName') !== 'admin' && val === 'next') {
        var anchorListHeight = 0
        var heightList = document.getElementsByClassName('el-table__row')
        if (this.dataList[0].remarks === '' || this.dataList[0].remarks === undefined) {
          if (heightList[0] === undefined) {
            heightList[0].offsetHeight = 0
          }
          window.scrollTo(0, 147.25 + listHead[0].offsetHeight)
          this.state = true
          return
        }
        anchorListHeight = 147.25 + listHead[0].offsetHeight + heightList[0].offsetHeight + 62
        for (var j = 0; j < this.reverseList.length; j++) {
          if (this.reverseList[j].fanRemarks === '' || this.reverseList[j].fanRemarks === undefined) {
            this.state = true
            window.scrollTo(0, anchorListHeight + listHead[1].offsetHeight)
            return
          }
          anchorListHeight += heightList[j + 1].offsetHeight
        }
        anchorListHeight = 147.25 + listHead[0].offsetHeight + listHead[1].offsetHeight + listHead[2].offsetHeight + heightList[0].offsetHeight + 62 + document.getElementsByClassName('el-table__body-wrapper is-scrolling-none')[1].offsetHeight + 62.25 //直到表头
        for (var k = 0; k < this.fivePoliticalList.length; k++) {
          if (this.fivePoliticalList[k].fiveRemarks === '' || this.fivePoliticalList[k].fiveRemarks === undefined) {
            this.state = true
            window.scrollTo(0, anchorListHeight)
            return
          }
          anchorListHeight += heightList[k + this.reverseList.length + 1].offsetHeight
        }
      }
      if (val === 'next') {
        if (this.pageNo === this.total) {
          alert(`当前是最后一页`)
        } else {
          valPage = this.pageNo + 1
          this.currentChangeHandle(valPage)
        }
      } else {
        if (this.pageNo === 1) {
          alert(`当前是第一页`)
        } else {
          valPage = this.pageNo - 1
          this.currentChangeHandle(valPage)
        }
      }
    },
    detail (id, name) {
        // 请求反向测评内容和五整治
        this.$http.get(`/peopleinformation/appraisalindicatorsdata/peopleAppraisalInformation/queryById?id=${id}`).then(({data}) => {
          var arr = []
          this[name + 's'] = []
          this[name] = []
          for (var i = 0; i < this.total; i++) {
              var list = []
              list.push(data.peopleAppraisalInformation.peopleAppraisalInformationAttachList)
              arr.push(this.$tool.deepClones(list))
              for (let j in arr[arr.length - 1]) {
                for (let k in arr[arr.length - 1][j]) {
                  this.$set(arr[arr.length - 1][j][k], 'mainId', this.dataLists[i].id)
                }
              }
          }
            this.$http({
              url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisget',
              method: 'get',
              params: {
                key: (localStorage.getItem('loginName') + this.$route.path + name)
              }
            }).then(({data}) => {
              if (localStorage.getItem('loginName') !== 'admin') {
                if (data.value === undefined || JSON.parse(data.value).length === 0) {
                  this[name + 's'] = arr
                  this[name] = this[name + 's'][0][0]
                } else {
                  this[name + 's'] = JSON.parse(data.value)
                  this[name] = this[name + 's'][0][0]
                }
              } else {
                this[name + 's'] = arr
                this[name] = this[name + 's'][0][0]
              }
            })
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageNo = 1
        this.refreshList()
      },
      // 当前页
      currentChangeHandle (val) {
        if (this.errList === '' || localStorage.getItem('loginName') === 'admin') {
          this.state = false
          this.$http({
            url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
            method: 'post',
            data: {
              key: (localStorage.getItem('loginName') + this.$route.path + 'zheng'),
              value: JSON.stringify(this.dataLists)
            }
          })
          this.$http({
            url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
            method: 'post',
            data: {
              key: (localStorage.getItem('loginName') + this.$route.path + 'reverseList'),
              value: JSON.stringify(this.reverseLists)
            }
          })
          this.$http({
            url: '/peopleinformation/administrativelevel/peopleAdministrativeLevel/Redisset',
            method: 'post',
            data: {
              key: (localStorage.getItem('loginName') + this.$route.path + 'fivePoliticalList'),
              value: JSON.stringify(this.fivePoliticalLists)
            }
          })
          this.redisFiveCount = 0
          this.redisFanCount = 0
          this.pageNo = val
          this.dataList = []
          this.reverseList = []
          this.fivePoliticalList = []
          this.dataList.push(this.dataLists[val - 1])
          this.reverseList = this.reverseLists[val - 1][0]
          this.fivePoliticalList = this.fivePoliticalLists[val - 1][0]
          window.scrollTo(0, 0)
        } else {
          this.state = true
        }
        // this.refreshList()
      },
      // 多选
      selectionChangeHandle (val) {
        this.dataListSelections = val
      },

    // 排序
      sortChangeHandle (obj) {
        if (obj.order === 'ascending') {
          this.orderBy = obj.prop + ' asc'
        } else if (obj.order === 'descending') {
          this.orderBy = obj.prop + ' desc'
        } else {
          this.orderBy = ''
        }
        this.refreshList()
      },
      // 新增
      add () {
        this.$refs.crowdMiddleleaderForm.init('add', '')
      },
      // 修改
      edit (id) {
        id = id || this.dataListSelections.map(item => {
          return item.id
        })[0]
        this.$refs.crowdMiddleleaderForm.init('edit', id)
      },
      // 查看
      view (id) {
        this.$refs.crowdMiddleleaderForm.init('view', id)
      },
      // 删除
      del (id) {
        let ids = id || this.dataListSelections.map(item => {
          return item.id
        }).join(',')
        this.$confirm(`确定删除所选项吗?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.loading = true
          this.$http({
            url: '/ticket/crowdmiddleleader/crowdMiddleleader/delete',
            method: 'delete',
            params: {'ids': ids}
          }).then(({data}) => {
            if (data && data.success) {
              this.$message.success(data.msg)
              this.refreshList()
            }
            this.loading = false
          })
        })
      },
      // 导入成功
      uploadSuccess (res, file) {
        if (res.success) {
          this.$message.success({dangerouslyUseHTMLString: true,
            message: res.msg})
        } else {
          this.$message.error(res.msg)
        }
      },
      // 下载模板
      downloadTpl () {
        this.$utils.download('/ticket/crowdmiddleleader/crowdMiddleleader/import/template')
      },
      exportExcel () {
        let params = {
          ...this.searchForm
        }
        this.$utils.download('/ticket/crowdmiddleleader/crowdMiddleleader/export', params)
      },
      resetSearch () {
        this.$refs.searchForm.resetFields()
        this.refreshList()
      }
    }
  }
</script>
<style>
  .tables .cell {
      white-space: pre-wrap;
  }
  .msgBox{
    width: auto !important;
  }
  .loadingStyle {
    font-size: 32px;
  }
</style>
